<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateWithdrawalsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('withdrawals', function (Blueprint $table) {
            $table->id();
            // 关联用户
            $table->unsignedBigInteger('user_id')->comment('用户ID');

            // 金额相关
            $table->decimal('amount', 10, 2)->comment('提现金额（单位：元）');
            $table->decimal('fee', 10, 2)->default(0)->comment('手续费');
            $table->decimal('arrival_amount', 10, 2)->comment('实际到账金额');

            // 提现状态
            $table->tinyInteger('status')->default(1)->comment('提现状态');

            // 时间信息
            $table->timestamp('applied_at')->useCurrent()->comment('申请时间');
            $table->timestamp('processed_at')->nullable()->comment('处理时间');

            // 审核信息（关联管理员）
            $table->unsignedBigInteger('user_bank_card_id')->nullable()->comment('银行卡ID');
            $table->string('audit_admin')->comment('审核人');
            $table->timestamp('audited_at')->nullable()->comment('审核时间');
            $table->text('reject_reason')->nullable()->comment('拒绝原因');
            $table->timestamps();
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `withdrawals` comment '提现申请'");
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('withdrawals');
    }
}
